xenstore: Do not assign to stdout/stderr/stdin - they are not
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 1 Aug 2007 18:17:08 +0000 (19:17 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 1 Aug 2007 18:17:08 +0000 (19:17 +0100)
implemented as variables on all systems.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/xenstore/utils.c
tools/xenstore/utils.h
tools/xenstore/xenstored_core.c

index d7f5219a871a0e0684ca2933a2f87d78d86039e2..a1ac12584a2321452b0b7d1d7fa5cb6edf297cb3 100644 (file)
 #include <signal.h>
 #include "utils.h"
 
-void xprintf(const char *fmt, ...)
+static void default_xprintf(const char *fmt, ...)
 {
        va_list args;
 
-       if (!stderr)
-               return; /* could trace()? */
-
        va_start(args, fmt);
        vfprintf(stderr, fmt, args);
        va_end(args);
        fflush(stderr);
 }
 
+void (*xprintf)(const char *fmt, ...) = default_xprintf;
+
 void barf(const char *fmt, ...)
 {
        char *str;
index ce14f3a408b1f85f294f123ec3ca194f1ecaa26d..f3783437078a7d602c3061623c804ca55ec30d54 100644 (file)
@@ -24,7 +24,7 @@ static inline bool strends(const char *a, const char *b)
 void barf(const char *fmt, ...) __attribute__((noreturn));
 void barf_perror(const char *fmt, ...) __attribute__((noreturn));
 
-void xprintf(const char *fmt, ...);
+void (*xprintf)(const char *fmt, ...);
 
 #define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
 
index fc3171f14b6d87c7cdbfe362ebed475f69d5950c..a969bcff56e49a05bd66bf8d23a88cd22b79fcaf 100644 (file)
@@ -1883,11 +1883,7 @@ int main(int argc, char *argv[])
                close(STDIN_FILENO);
                close(STDOUT_FILENO);
                close(STDERR_FILENO);
-
-               /* Get ourselves a nice xenstored crash if these are used. */
-               stdin = NULL;
-               stdout = NULL;
-               stderr = NULL;
+               xprintf = trace; /* xprintf() must not use stderr */
        }
 
        signal(SIGHUP, trigger_reopen_log);